﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Form_YOLO_NET8
{
    public class LogMessage
    {
        private static string logDirectory = Directory.GetCurrentDirectory() + "\\Logs";

   


        public static void WriteLog(string message, LogLevel level = LogLevel.Info)
        {
            if (!Directory.Exists(logDirectory))
            {
                Directory.CreateDirectory(logDirectory);
            }

            string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
            string logLevelString = level.ToString();
            string logMessage = $"{timestamp} [{logLevelString}] {message}{Environment.NewLine}";

            string logFileName = Path.Combine(logDirectory, $"{DateTime.Now:yyyyMMdd}.log");
            File.AppendAllText(logFileName, logMessage);
        }

        public enum LogLevel
        {
            Info,
            Warning,
            Error,
            Debug
        }
    }
}
